#include "btmusic.h"
#include "sys_app.h"
#include "msg_manager.h"

static int btmusic_init(void)
{
    ESP_LOGI(TAG, "%s: enter", __func__);

    return 0;
}

static int btmusic_exit(void)
{
    ESP_LOGI(TAG, "%s: enter", __func__);

    return 0;
}

void btmusic_main_loop(void *arg)
{
    struct app_msg* msg = NULL;

    while (sys_get_cur_app() == SYS_APP_BTMUSIC) {
        if (msg_manager_receive_msg(&msg, portMAX_DELAY)) {
            ESP_LOGI(TAG, "%s: receive msg type: %d, cmd: %d, value: %08x", __func__, msg->type, msg->cmd, msg->value);
            switch (msg->type) {
                case MSG_INIT_APP:
                    btmusic_init();
                break;

                case MSG_EXIT_APP:
                    btmusic_exit();
                break;

                default:
                    ESP_LOGE(TAG, "%s: unknown msg type: %d", __func__, msg->type);
                break;
            }
            msg_manager_receive_exit(msg);
        }
    }
}
